package Controls;

import Forms.ColorPallete;
import Core.Control;
import Core.GM;
import javax.microedition.lcdui.Graphics;

public class ColorSelector extends Control
{
	private int color;
	private boolean editable=true;
	
	public ColorSelector(int color, int size)
	{
		super(size, size);
		setColor(color);

		selectedAction = "Edit";
	}

	public ColorSelector(int color, int size, boolean editable)
	{
		super(size, size);
		setColor(color);

		this.editable = selectable = editable;

		selectedAction = "Edit";
	}

	public void draw(Graphics g, int x, int y)
	{
		g.setColor(color);
		g.fillRect(x, y, W, H);
		super.draw(g, x, y);
	}

	public void release()
	{
		super.release();
		new ColorPallete(color);
	}

	public void onEvent(int event, Object param)
	{
		if(event == GM.UPPER_FORM_CLOSED && (param instanceof ColorPallete))
		{
			color = ((ColorPallete)param).getColor();
		}

		System.out.println("Event");
	}

	public void setColor(int color)
	{
		this.color = color;
	}

	public int getColor()
	{
		return color;
	}
}
